﻿using System;

namespace SystemWnioskujacy
{
    public class Queries
    {
        private Query[] qTab = new Query[0];

        public int Length
        {
            get
            {
                return qTab.Length;
            }
        }

        public Query this[int i]
        {
            get
            {
                return qTab[i];
            }
        }

        public void Add(Query nQuery)
        {
            Query[] nTab = new Query[qTab.Length + 1];

            Array.Copy(qTab, nTab, qTab.Length);
            nTab[nTab.Length - 1] = nQuery;

            qTab = nTab;
        }

        public void Remove(Query oQuery)
        {
            for (int i = 0; i < qTab.Length; i++)
            {
                if (qTab[i].Equals(oQuery))
                {
                    Query[] nTab = new Query[qTab.Length - 1];

                    Array.Copy(qTab, nTab, i);
                    Array.Copy(qTab, i + 1, nTab, i, qTab.Length - i - 1);

                    qTab = nTab;
                    break;
                }
            }
        }

        public void Remove(int i)
        {
            if (qTab.Length > i)
            {
                Query[] nTab = new Query[qTab.Length - 1];

                Array.Copy(qTab, nTab, i);
                Array.Copy(qTab, i + 1, nTab, i, qTab.Length - i - 1);

                qTab = nTab;
            }
        }
    }
}
